package com.ncmx.config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import com.ncmx.engine.dao.OrderEntryDao;
import com.ncmx.engine.dao.TradeMgmtDao;
import com.ncmx.lmax.engine.MatchingEngine;
import com.ncmx.lmax.engine.essentials.AppEnums.SymbolEnum;
import com.ncmx.lmax.engine.essentials.MatchingUnit;

@Configuration
public class JavaConfig {

	@Bean
	public Map<String, MatchingEngine> symbolMatchingEngines() {
		Map<String, MatchingEngine> symbolMatchingEngines = new HashMap<>(
				SymbolEnum.values().length);
		for (SymbolEnum symbolEnum : SymbolEnum.values()) {

			switch (symbolEnum) {
			case ALUMINIUM_L:symbolMatchingEngines.put(symbolEnum.toString(),new MatchingEngine(aluminium_l_matchingunit()) ) ;
				break;
			case BRCRUDE_OIL:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(brcrude_oil_matchingunit()));
				break;
			case COPPER_L:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(copper_l_matchingunit()));
				break;
			case COPPER_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(copper_s_matchingunit()));
				break;
			case ALUMINIUM_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(aluminium_s_matchingunit()));
				break;
			case CRUDE_OIL:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(crude_oil_matchingunit()));
				break;
			case GOLD_L:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(gold_l_matchingunit()));
				break;
			case GOLD_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(gold_s_matchingunit()));
				break;
			case LEAD_L:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(lead_l_matchingunit()));
				break;
			case LEAD_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(lead_s_matchingunit()));
				break;
			case NATURAL_GAS:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(natural_gas_matchingunit()));
				break;
			case NICKEL_L:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(nickel_l_matchingunit()));
				break;
			case NICKEL_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(nickel_s__matchingunit()));
				break;
			case SILVER_L:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(silver_l_matchingunit()));
				break;
			case SILVER_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(silver_s_matchingunit()));
				break;
			case ZINC_L:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(zinc_l_matchingunit()));
				break;
			case ZINC_S:symbolMatchingEngines.put(symbolEnum.toString(), new MatchingEngine(zinc_s_matchingunit()));
				break;
			default:
				break;

			}



			/*
			 * symbolMatchingEngines.put(symbolEnum.toString(), new
			 * MatchingEngine(symbolEnum.toString()));
			 */
		}
		System.out.println(symbolMatchingEngines.values());
		return symbolMatchingEngines;
	}

	@Bean
	public List<SymbolEnum> symbolEnum() {
		List<SymbolEnum> symbolList = new ArrayList<>();
		symbolList.addAll(Arrays.asList(SymbolEnum.values()));
		return symbolList;
	}

	@Bean
	public MatchingUnit aluminium_l_matchingunit() {

		return new MatchingUnit("ALUMINIUM_L");
	}

	@Bean
	public MatchingUnit aluminium_s_matchingunit() {
		return new MatchingUnit("ALUMINIUM_S");
	}

	
	@Bean
	public MatchingUnit brcrude_oil_matchingunit() {
		return new MatchingUnit("BRCRUDE_OIL");
	}
	@Bean
	public MatchingUnit copper_l_matchingunit() {
		return new MatchingUnit("COPPER_L");
	}
	@Bean
	public MatchingUnit copper_s_matchingunit() {
		return new MatchingUnit("COPPER_S");
	}
	@Bean
	public MatchingUnit crude_oil_matchingunit() {
		return new MatchingUnit("CRUDE_OIL");
	}
	@Bean
	public MatchingUnit gold_l_matchingunit() {
		return new MatchingUnit("GOLD_L");
	}
	@Bean
	public MatchingUnit gold_s_matchingunit() {
		return new MatchingUnit("GOLD_S");
	}
	@Bean
	public MatchingUnit lead_l_matchingunit() {
		return new MatchingUnit("LEAD_L");
	}
	@Bean
	public MatchingUnit lead_s_matchingunit() {
		return new MatchingUnit("LEAD_S");
	}
	@Bean
	public MatchingUnit natural_gas_matchingunit() {
		return new MatchingUnit("NATURAL_GAS");
	}
	@Bean
	public MatchingUnit silver_l_matchingunit() {
		return new MatchingUnit("SILVER_L");
	}
	@Bean
	public MatchingUnit silver_s_matchingunit() {
		return new MatchingUnit("SILVER_S");
	}
	@Bean
	public MatchingUnit zinc_l_matchingunit() {
		return new MatchingUnit("ZINC_L");
	}
	@Bean
	public MatchingUnit zinc_s_matchingunit() {
		return new MatchingUnit("ZINC_S");
	}
	@Bean
	public MatchingUnit nickel_l_matchingunit() {
		return new MatchingUnit("NICKEL_L");
	}
	@Bean
	public MatchingUnit nickel_s__matchingunit() {
		return new MatchingUnit("NICKEL_S");
	}
	
	@Bean
	@Scope("prototype")
	public TradeMgmtDao tradeMgmtDAO() {
		return new TradeMgmtDao();
	}
	
	@Bean
	@Scope("prototype")
	public OrderEntryDao orderEntryDao() {
		return new OrderEntryDao();
	}

}
